﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xinkui.WebModel.BasicControl;
using Xinkui.WebModel.Cache;
using Xinkui.DataAccess.AutoGenerator;
using Xinkui.Common;
using Xinkui.WebModel.Cache.View;

public partial class UserControl_fore_UC_Home_Banner : ForeControl {
    private int _LastSize = 4;
    public int LastSize {
        get {
            return _LastSize;
        }
        set {

            _LastSize = value;
        }
    }


    private int _CategorySize = 4;
    public int CategorySize {
        get {
            return _CategorySize;
        }
        set {

            _CategorySize = value;
        }
    }





    protected void Page_Load(object sender, EventArgs e) {
        rptCategoryRoot.DataSource = CategoryCache.ListAllCategory();
        rptCategoryRoot.DataBind();

        rptLastProductDataSource.DataSource = Singleton<ProductInfoDataAccess>.Instance.ListLastProduct(_LastSize);
        rptLastProductDataSource.DataBind();

        rptLastBuyleads.DataSource = Singleton<BuyleadInfoDataAccess>.Instance.ListLastBuylead(LastSize);
        rptLastBuyleads.DataBind();

        var allCategory = CategoryCache.ListAllCategory().Take(5);

        List<CategoryView> views = new List<CategoryView>(allCategory);

        foreach (var root in views) {
            root.SubViews = root.SubViews.Take(_CategorySize).ToList();
        }
        this.rptRecommendCategory.DataSource = views;
        this.rptRecommendCategory.DataBind();
    }
}